Stored Procedures [dbo].[sp_asi_GetCounter2]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)Direction
@CounterNamevarchar(30)30
@CounterValueint4Out
Permissions
TypeActionOwning Principal
GrantExecuteIMIS
SQL Script
CREATE PROCEDURE sp_asi_GetCounter2 @CounterName varchar(30), @CounterValue int out
AS
if not exists (select COUNTER_NAME from Counter where COUNTER_NAME=@CounterName)
insert Counter (COUNTER_NAME, LAST_VALUE) values (@CounterName,0)
update Counter
set LAST_VALUE=LAST_VALUE + 1, LAST_UPDATED=getdate(),
UPDATED_BY=user_name()
where COUNTER_NAME= @CounterName
select @CounterValue = LAST_VALUE from Counter where COUNTER_NAME= @CounterName

GO
GRANT EXECUTE ON  [dbo].[sp_asi_GetCounter2] TO [IMIS]
GO
Uses
Used By